import React  from 'react';
import { withRouter } from 'react-router-dom';
import { ActionSheet,Tools} from 'weaver-mobile';
import ComFloatTouch from "../../../governTools/comFloatTouch/comFloatTouch.js";
const getLabel = Tools.getLabel;

const isIPhone = new RegExp('\\biPhone\\b|\\biPod\\b', 'i').test(window.navigator.userAgent);
let wrapProps;
if (isIPhone) {
  wrapProps = {
    onTouchStart: e => e.preventDefault(),
  };
}
@withRouter
/*
 * @info: 评论/汇报的评论动作组件
 * @Author: lusx
 * @Date: 2019-12-01 11:13:16
 * @Last modified by:   lusx
 * @Last modified time: 26-04-2019 05:06:07
 */
export default class ActionPage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      clicked: 'none'
    };
  }
  render() {
    return(
      <div className="g-actionPage">
          <ComFloatTouch icon="sign" color="#ddd" onClick={this.showActionSheet} />
      </div>
    );
  }
  showActionSheet = () => {
    const {match:{url},location:{search},showReportButton} = this.props;
    let BUTTONS = [
      {
        content: "反馈",//getLabel("280","汇报"),
        onClick: () => this.props.history.push(`${url}/edit/editReport${search}`),
      },
      {
        content: "批示",//getLabel("675","评论"),
        onClick: () => this.props.history.push(`${url}/edit/editComment${search}`),
      },
      {
        content: getLabel("201","取消"),
      },
    ];
    BUTTONS = BUTTONS.slice(showReportButton===true?0:1);
    ActionSheet.showActionSheetWithOptions({
      options: BUTTONS,
      cancelButtonIndex: BUTTONS.length - 1,
      maskClosable: true,
      'data-seed': 'logId',
      wrapProps,
    },
    (buttonIndex) => {
      this.setState({ clicked: BUTTONS[buttonIndex] });
    });

  }
}
